#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *line = NULL;
    ssize_t nread;
    size_t len;
    FILE *stream;
    
    stream = fopen("./testfile", "r");
    if (stream == NULL) {
        perror("fopen");
        exit(EXIT_FAILURE);
    }

    while ((nread = getline(&line, &len, stream )) != -1) {
        printf("Retrieved line of length %zu:\n", nread);
        fwrite(line, nread, 1, stdout);
    }

    free(line);
    fclose(stream);

    return 0;
}
